﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using XPExplorerBar;
using WHC.Hotel.Entity;
using WHC.Hotel.BLL;
using WeifenLuo.WinFormsUI.Docking;

namespace WHC.Hotel.UI
{
    public partial class FrmStatus : DockContent
    {
        public Dictionary<string, List<CListItem>> DisplayItems = new Dictionary<string, List<CListItem>>();

        public void InitDisplayItems()
        {
            #region 构造测试内容

            DisplayItems.Clear();
            List<CListItem> subItems = new List<CListItem>();
            subItems.Add(new CListItem("宾客姓名：", ""));
            subItems.Add(new CListItem("预设单价：", ""));
            subItems.Add(new CListItem("折后单价：", ""));
            subItems.Add(new CListItem("房间电话：", ""));
            subItems.Add(new CListItem("所在区域：", ""));
            subItems.Add(new CListItem("进店时间：", ""));
            subItems.Add(new CListItem("已用时间：", ""));
            subItems.Add(new CListItem("已交金额：", ""));
            subItems.Add(new CListItem("应收金额：", ""));
            DisplayItems.Add("标准单人间", subItems);

            RoomStatusInfo statusInfo = BLLFactory<Room>.Instance.GetStatus();
            subItems = new List<CListItem>();
            //subItems.Add(new CListItem("房间总数：", statusInfo.All.ToString()));
            //subItems.Add(new CListItem("当前可供：", statusInfo.Availables.ToString()));
            //subItems.Add(new CListItem("当前占用：", statusInfo.Occupies.ToString()));
            //subItems.Add(new CListItem("当前预定：", statusInfo.BookIns.ToString()));
            //subItems.Add(new CListItem("长 包 房：", statusInfo.Contracts.ToString()));
            //subItems.Add(new CListItem("当前停用：", statusInfo.Stops.ToString()));
            //subItems.Add(new CListItem("当前清理：", statusInfo.Cleans.ToString()));
            //subItems.Add(new CListItem("总入住率：", statusInfo.InRoomRate));
            DisplayItems.Add("总房态", subItems);
            #endregion
        }

        public FrmStatus()
        {
            InitializeComponent();

            InitDisplayItems();
        }

        public void UpdateContent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmStatus));

            this.taskPane1.Expandos.Clear();
            Point startLoaction = new Point(12, 12);
            int panelPadding = 12;
            Size expandSize = new Size(168, 350);

            Point itemStartLocation = new Point(11, 36);
            int itemPadding = 25;
            int itemSpacing = 64;

            int k = 0;
            foreach (string itemName in DisplayItems.Keys)
            {
                Expando expandDo = new Expando();
                expandDo.Text = itemName;
                expandDo.SpecialGroup = true;
                expandDo.TitleImage = ((System.Drawing.Image)(resources.GetObject("expando1.TitleImage")));
                expandDo.Size = expandSize;
                expandDo.ExpandedHeight = expandSize.Height;

                expandDo.Location = new Point(startLoaction.X,
                        startLoaction.Y + (expandSize.Height + panelPadding) * k);
                k++;

                List<CListItem> subItemList = DisplayItems[itemName];
                for (int i = 0; i < subItemList.Count; i++)
                {
                    Label lblTitle = new Label();
                    lblTitle.AutoSize = true;
                    lblTitle.Font = new Font("宋体", 9.0F);
                    lblTitle.Text = subItemList[i].Text;
                    lblTitle.Location = new Point(itemStartLocation.X,
                        itemStartLocation.Y + itemPadding * i);

                    Label lblValue = new Label();
                    lblValue.AutoSize = true;
                    lblValue.Font = new Font("宋体", 9.0F);
                    lblValue.ForeColor = Color.Blue;
                    lblValue.Text = subItemList[i].Value;
                    lblValue.Location = new Point(itemStartLocation.X + itemSpacing,
                        itemStartLocation.Y + itemPadding * i);

                    expandDo.Items.AddRange(new Control[] { lblTitle, lblValue });
                }
                this.taskPane1.Expandos.Add(expandDo);
            }
            this.taskPane1.Refresh();
        }

        private void FrmStatus_Load(object sender, EventArgs e)
        {
            UpdateContent();
        }
    }
}
